break;
case PROP_PROFILE:
- priv->profile = g_value_get_enum (value);
+ gdk_gl_context_set_profile (GDK_GL_CONTEXT (gobject), g_value_get_enum (value));
break;
default:
GDK_TYPE_GL_PROFILE,
GDK_GL_PROFILE_DEFAULT,
G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
/**
return priv->window;
}
+/**
+ * gdk_gl_context_set_profile:
+ * @context: a #GdkGLContext
+ * @profile: the profile for the context
+ *
+ * Sets the profile used when realizing the context.
+ *
+ * The #GdkGLContext must not be realized or made current prior to calling
+ * this function.
+ *
+ * Since: 3.16
+ */
+void
+gdk_gl_context_set_profile (GdkGLContext *context,
+ GdkGLProfile profile)
+{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+
+ g_return_if_fail (GDK_IS_GL_CONTEXT (context));
+ g_return_if_fail (!priv->realized);
+
+ if (priv->profile != profile)
+ {
+ priv->profile = profile;
+
+ g_object_notify_by_pspec (G_OBJECT (context), obj_pspecs[PROP_PROFILE]);
+ }
+}
+
/**
* gdk_gl_context_get_profile:
* @context: a #GdkGLContext
*
- * Retrieves the #GdkGLProfile that @context was created for.
+ * Retrieves the #GdkGLProfile set using gdk_gl_context_set_profile().
*
* Returns: a #GdkGLProfile
*
GDK_AVAILABLE_IN_3_16
GdkWindow * gdk_gl_context_get_window (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
-GdkGLProfile gdk_gl_context_get_profile (GdkGLContext *context);
-GDK_AVAILABLE_IN_3_16
GdkGLContext * gdk_gl_context_get_shared_context (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
gboolean compatible);
GDK_AVAILABLE_IN_3_16
gboolean gdk_gl_context_get_forward_compatible (GdkGLContext *context);
+GDK_AVAILABLE_IN_3_16
+void gdk_gl_context_set_profile (GdkGLContext *context,
+ GdkGLProfile profile);
+GDK_AVAILABLE_IN_3_16
+GdkGLProfile gdk_gl_context_get_profile (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
gboolean gdk_gl_context_realize (GdkGLContext *context,
GError **error);
-
GDK_AVAILABLE_IN_3_16
void gdk_gl_context_make_current (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
window->impl_window->gl_paint_context =
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window->impl_window,
TRUE,
- GDK_GL_PROFILE_DEFAULT,
NULL,
&internal_error);
}
/**
* gdk_window_create_gl_context:
* @window: a #GdkWindow
- * @profile: the GL profile the context should target
* @error: return location for an error
*
* Creates a new #GdkGLContext matching the
* If the creation of the #GdkGLContext failed, @error will be set.
*
* Before using the returned #GdkGLContext, you will need to
- * call gdk_gl_context_make_current().
+ * call gdk_gl_context_make_current() or gdk_gl_context_realize().
*
* Returns: (transfer full): the newly created #GdkGLContext, or
* %NULL on error
**/
GdkGLContext *
gdk_window_create_gl_context (GdkWindow *window,
- GdkGLProfile profile,
GError **error)
{
GdkGLContext *paint_context;
return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window->impl_window,
FALSE,
- profile,
paint_context,
error);
}
GDK_AVAILABLE_IN_3_16
GdkGLContext * gdk_window_create_gl_context (GdkWindow *window,
- GdkGLProfile profile,
GError **error);
G_END_DECLS
GdkEvent *event);
GdkGLContext *(*create_gl_context) (GdkWindow *window,
gboolean attached,
- GdkGLProfile profile,
GdkGLContext *share,
GError **error);
gboolean (* realize_gl_context) (GdkWindow *window,
return FALSE;
}
+ /* "default profile" means 3.2 core profile */
+ if (profile == GDK_GL_PROFILE_DEFAULT)
+ profile = GDK_GL_PROFILE_3_2_CORE;
+
if (profile != GDK_GL_PROFILE_3_2_CORE)
{
g_set_error_literal (error, GDK_GL_ERROR,
static GdkGLContext *
gdk_mir_window_impl_create_gl_context (GdkWindow *window,
gboolean attached,
- GdkGLProfile profile,
GdkGLContext *share,
GError **error)
{
return NULL;
}
- if (profile == GDK_GL_PROFILE_DEFAULT)
- profile = GDK_GL_PROFILE_3_2_CORE;
-
- if (profile == GDK_GL_PROFILE_3_2_CORE &&
- !_gdk_mir_display_have_egl_khr_create_context (display))
+ if (!_gdk_mir_display_have_egl_khr_create_context (display))
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
"display", display,
"window", window,
- "profile", profile,
"shared-context", share,
NULL);
gboolean debug_bit, forward_bit;
int i = 0;
+ /* default profile means 3.2 core profile */
+ if (profile == GDK_GL_PROFILE_DEFAULT)
+ profile = GDK_GL_PROFILE_3_2_CORE;
+
if (profile != GDK_GL_PROFILE_3_2_CORE)
{
g_set_error_literal (error, GDK_GL_ERROR,
GdkGLContext *
gdk_wayland_window_create_gl_context (GdkWindow *window,
gboolean attached,
- GdkGLProfile profile,
GdkGLContext *share,
GError **error)
{
return NULL;
}
- if (profile == GDK_GL_PROFILE_DEFAULT)
- profile = GDK_GL_PROFILE_3_2_CORE;
-
- if (profile == GDK_GL_PROFILE_3_2_CORE &&
- !display_wayland->have_egl_khr_create_context)
+ if (!display_wayland->have_egl_khr_create_context)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
"display", display,
"window", window,
- "profile", profile,
"shared-context", share,
NULL);
gboolean gdk_wayland_display_init_gl (GdkDisplay *display);
GdkGLContext * gdk_wayland_window_create_gl_context (GdkWindow *window,
gboolean attach,
- GdkGLProfile profile,
GdkGLContext *share,
GError **error);
void gdk_wayland_window_invalidate_for_new_frame (GdkWindow *window,
{
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
GdkGLProfile profile = gdk_gl_context_get_profile (context);
-
GdkWin32GLContext *context_win32 = GDK_WIN32_GL_CONTEXT (context);
/* These are the real WGL context items that we will want to use later */
GdkGLContext *
_gdk_win32_window_create_gl_context (GdkWindow *window,
gboolean attached,
- GdkGLProfile profile,
GdkGLContext *share,
GError **error)
{
}
/* We first check whether we have WGL_ARB_create_context... */
-
- if (profile == GDK_GL_PROFILE_3_2_CORE &&
- !display_win32->hasWglARBCreateContext)
+ if (!display_win32->hasWglARBCreateContext)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT,
"display", display,
"window", window,
- "profile", profile,
"shared-context", share,
NULL);
GdkGLContext *
_gdk_win32_window_create_gl_context (GdkWindow *window,
gboolean attached,
- GdkGLProfile profile,
GdkGLContext *share,
GError **error);
profile = gdk_gl_context_get_profile (context);
share = gdk_gl_context_get_shared_context (context);
+ /* default means 3.2 core profile */
+ if (profile == GDK_GL_PROFILE_DEFAULT)
+ profile = GDK_GL_PROFILE_3_2_CORE;
+
/* we check for the presence of the GLX_ARB_create_context_profile
- * extension before checking for a GLXFBConfig.
+ * extension before checking for a GLXFBConfig when creating the
+ * GdkX11GLContext instance in gdk_x11_window_create_gl_context().
*/
if (profile == GDK_GL_PROFILE_3_2_CORE)
{
GdkGLContext *
gdk_x11_window_create_gl_context (GdkWindow *window,
gboolean attached,
- GdkGLProfile profile,
GdkGLContext *share,
GError **error)
{
display = gdk_window_get_display (window);
- /* GDK_GL_PROFILE_DEFAULT is currently equivalent to the 3_2_CORE profile */
- if (profile == GDK_GL_PROFILE_DEFAULT)
- profile = GDK_GL_PROFILE_3_2_CORE;
-
if (!gdk_x11_screen_init_gl (gdk_window_get_screen (window)))
{
g_set_error_literal (error, GDK_GL_ERROR,
return NULL;
}
- if (profile == GDK_GL_PROFILE_3_2_CORE &&
- !GDK_X11_DISPLAY (display)->has_glx_create_context)
+ if (!GDK_X11_DISPLAY (display)->has_glx_create_context)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
context = g_object_new (GDK_TYPE_X11_GL_CONTEXT,
"display", display,
"window", window,
- "profile", profile,
"shared-context", share,
NULL);
- context->profile = profile;
context->glx_config = config;
context->is_attached = attached;
gboolean gdk_x11_screen_init_gl (GdkScreen *screen);
GdkGLContext * gdk_x11_window_create_gl_context (GdkWindow *window,
gboolean attached,
- GdkGLProfile profile,
GdkGLContext *share,
GError **error);
void gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
GError *error = NULL;
GdkGLContext *context;
- context = gdk_window_create_gl_context (gtk_widget_get_window (widget), priv->profile, &error);
+ context = gdk_window_create_gl_context (gtk_widget_get_window (widget), &error);
if (priv->error != NULL)
{
gtk_gl_area_set_error (area, error);
return NULL;
}
+ gdk_gl_context_set_profile (context, priv->profile);
+
gdk_gl_context_realize (context, &error);
if (priv->error != NULL)
{